#pragma once

#include <iostream>
#include <string>
#include <memory>
#include "Socket.hpp"
#include "Log.hpp"

using namespace SocketModule;
using namespace LogModule;

const int gdefaultfd = -1;

class EpollServer
{
    static const int revs_num = 64;

    public:
        EpollServer(uint16_t port)
            :_port(port)
            ,_listen_sockfd(std::make_unique<TcpSocket>())
            ,_isrunning(false)
        {

        }

        void Init()
        {
            _listen_sockfd->BuildTcpSocketMethod(_port);

        }

        void Loop()
        {

        }



        ~EpollServer()
        {
            _listen_sockfd->Close();
            if(_epfd >= 0)
                close(_epfd);

        }
    private:
        uint16_t _port;
        std::unique_ptr<Socket> _listen_sockfd;
        bool _isrunning; 
        int _epfd;
        struct epoll_event _revs[revs_num];
};